import { cloudbaseApp, development } from '@/cloudbaseapi/cloudbase-api'
const db = cloudbaseApp().database()
const $ = db.command.aggregate
const _ = db.command
const { USERDB } = development()

export async function getUserList(count, page) {
  const limit = count || 10
  const skip = ((page || 1) - 1) * limit
  const data = await db.collection(USERDB).limit(limit).skip(skip).field({
    avatarUrl: true, email: true, nickName: true, openid: true, uid: true, wxOpenId: true, loginType: true
  }).get()
  const total = await db.collection(USERDB).count()
  data.total = total.total
  return data
}
